package com.csun.cmny.provider.controller.rpc;

import com.csun.cmny.provider.model.service.UacRoleFeignApi;
import com.csun.cmny.provider.model.vo.RpcRoleVo;
import com.csun.cmny.provider.resolver.CmnyMessageSource;
import com.csun.cmny.provider.service.UacRoleService;
import com.csun.cmny.util.wrapper.WrapMapper;
import com.csun.cmny.util.wrapper.Wrapper;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2019-05-31 13:59
 * @Description: the class uac role feign client
 */
@Slf4j
@RestController
@Api(value = "API - UacRoleFeignClient", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class UacRoleFeignClient implements UacRoleFeignApi {

    @Resource
    private UacRoleService uacRoleService;

    @Resource
    private CmnyMessageSource cmnyMessageSource;
    /**
     * 超时token更新为离线.
     *
     * @param userId
     * @return the wrapper
     */
    @Override
    public Wrapper queryRoleListByUserId(@RequestParam("userId") Long userId) {

        List<RpcRoleVo> rpcRoleVoList = uacRoleService.queryRoleListByUserId(userId);

        //return WrapMapper.ok(rpcRoleVoList);
        return WrapMapper.wrap(Wrapper.SUCCESS_CODE, cmnyMessageSource
                .getMessage("operation.success", null), rpcRoleVoList);
    }
}
